public class RobotRegulier extends Robot
{
	public RobotRegulier(Labyrinthe lab)
	{
		super(lab, new int[]{Labyrinthe.UP, Labyrinthe.RIGHT, Labyrinthe.DOWN, Labyrinthe.LEFT});
	}
	
	public RobotRegulier(Labyrinthe lab, int[] prefs)
	{
		super(lab, prefs);
	}

	public int findExit()
	{
		int ct = 0;
		while (!laby.isExit()) //not found (yet)
		{
			boolean found = false;
			for (int d: preferences)
			{
				if (super.canVisit(d) && super.move(d))
				{
					ct++;
					found = true;
					break;
				}
			}
			if (!found) //backtrack
			{
				for (int d: preferences)
				{
					if (!super.isWall(d))
					{
						ct++;
						super.setWall();
						super.move(d);
					}
				}
			}
		}
		return ct;
	}
	
}
